/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pojo;

import java.sql.ResultSet;
import util.MySQLDataAccessHelper;

/**
 *
 * @author Rocker000
 */
public class ChiTietGioHang_pojo 
{
    private int machitiet;
    private int magiohang;
    private int soluong;
    private String masanpham;

    public ChiTietGioHang_pojo() {
    }

    public int getMachitiet() {
        return machitiet;
    }

    public void setMachitiet(int machitiet) {
        this.machitiet = machitiet;
    }

    public int getMagiohang() {
        return magiohang;
    }

    public void setMagiohang(int magiohang) {
        this.magiohang = magiohang;
    }

    public String getMasanpham() {
        return masanpham;
    }

    public void setMasanpham(String masanpham) {
        this.masanpham = masanpham;
    }

    public int getSoluong() {
        return soluong;
    }

    public void setSoluong(int soluong) {
        this.soluong = soluong;
    }
    public ChiTietGioHang_pojo( int magiohang, String masanpham, int soluong) {        
        this.magiohang = magiohang;
        this.masanpham= masanpham;
        this.soluong = soluong;
    }
    
    public SanPham_pojo SanPhamTuongUng()
    {
        String sql = String.format("select*from sanpham where magiay = '%s'",this.masanpham);
        SanPham_pojo temp = new SanPham_pojo();
        try
        {
            MySQLDataAccessHelper helper = new MySQLDataAccessHelper();
            helper.Open();
            ResultSet rs = helper.ExeCuteQuery(sql);
            if(rs.next())
            {                
                temp.setTenSanPham(rs.getString("tensanpham"));
                temp.setGia(rs.getDouble("gia"));
                temp.setHieu(rs.getString("hieu"));
                temp.setImage(rs.getString("Image"));
                temp.setKichThuoc(rs.getFloat("kichthuoc"));
                temp.setMaSanPham(rs.getString("masanpham"));
                temp.setSoLuongTon(rs.getInt("soluongton"));
                temp.setSoLuotMua(rs.getInt("luotmua"));
                temp.setChiTietSanPham(rs.getString("chitietsanpham"));
                temp.setMaLoai(rs.getString("maloaisanpham"));              
            }
                
            helper.Close();
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }
        return temp;
    }        
    
}
